#ifndef INCLUDED_TASKMANAGER_H
#define INCLUDED_TASKMANAGER_H

#include "XmlNode.h"
#include "basetask.h"
#include "StanzaManager.h"
#include <vector>

namespace tinkle {

class Task;

class TaskManager : public BaseTask, public sigslot::has_slots<>{
public:
    // a stanza manager should be passed, because our client is for Xmpp
    // protocol, a stanza manager is necessary
    TaskManager(StanzaManager *stanzaMgr);
    ~TaskManager();
    // all task will run via the task manager
    void StartTask(Task *task);

    void AbortTask(Task *task);
    void Handle();
    void Handle(XmlNode *stanza);

    StanzaManager *GetStanzaManager() const;

private:
    void RunTasks();
    int ProcessReady();
    void OnStanzaRead(StanzaManager *stanzaMgr);

    StanzaManager *_stanzaMgr;
    std::vector<Task *> _taskQ;
};

}

#endif